# -*- coding: utf-8 -*-
"""
@Time : 2024/3/5 11:11 PM
@Author: imamhusan
@Des: 收藏和观看模型
"""
from tortoise import Model, fields


class MyTime(Model):
    create_time = fields.DatetimeField(auto_now_add=True, description='创建时间')
    update_time = fields.DatetimeField(auto_now=True, description='更新时间')

    class Meta:
        abstract = True


class Favor(MyTime):
    user = fields.ForeignKeyField(model_name='base.User', related_name='favors')
    goods = fields.ForeignKeyField(model_name='base.Goods', related_name='favors')
    state = fields.IntField(description='状态 0：未收藏 1：已收藏', default=1)

    class Meta:
        table = 'oz_favor'
        table_description = '收藏表'


class ViewLog(MyTime):
    user = fields.ForeignKeyField(model_name='base.User', related_name='viewlog')
    goods = fields.ForeignKeyField(model_name='base.Goods', related_name='viewlog')

    class Meta:
        table = 'oz_view_log'
        table_description = '观看表'
